<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/7/4
 * Time: 16:38
 * Project name: PHPTEST
 * File name: 1.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */

$url = "http://msracn.chinanorth.cloudapp.chinacloudapi.cn/msr-periodical/%E5%BE%AE%E8%BD%AF%E4%BA%9A%E6%B4%B2%E7%A0%94%E7%A9%B6%E9%99%A2%E9%80%9A%E8%AE%AF-4/";
$str = file_get_contents($url);
preg_match("/<!---->.*?<!---->/si",$str,$result);
$s = $result[0];
//var_dump($result[0]);
//preg_match("/<!--unsubscribe-->.*?<!--unsubscribe-->/si",$str,$result);

$button = "<p style='text-align: right'><a href='1.php'>取消订阅</a></p>";
$s = preg_replace_callback(
	"/<!--unsubscribe-->.*?<!--unsubscribe-->/si",
	function ($matches) use($button){
		$matches[0] = $button;
		return $button;
	},$s
);
echo $s;